<?php
	function getAccessToken($appid ,$secret){
		$url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$appid .'&secret='.$secret;
		$data = null;
		$curl = curl_init();
		curl_setopt($curl, CURLOPT_URL, $url);
		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
		curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
		if (!empty($data)){
			curl_setopt($curl, CURLOPT_POST, 1);
			curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
		}
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
		$output = curl_exec($curl);
		curl_close($curl);
		$json = json_decode($output);
		return $json->access_token;
	}
	
	
	
	function getAccessToken2($appid ,$secret){
		$url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$appid .'&secret='.$secret;
		$output = file_get_contents($curl);
		curl_close($curl);
		$json = json_decode($output);
		return $json->access_token;
	}
	
	function test() {
		phpinfo();
	}
?>